public class DebtAcnt extends Account
{

	final double MINIMUM_PAYMENT_PERCENT = 0.04;

	public DebtAcnt(double bal, double rate, Account ofl, Account ufl,
			Account ira, double lThresh, double hThresh)
	{
		name = "Debt";
		balance = bal;
		anualInterestRate = rate;
		monthlyInterestRate = rate / 12;
		overFlowAccount = ofl;
		underFlowAccount = ufl;
		interestRecievingAccount = ira;
		lowThreshold = lThresh;
		highThreshold = hThresh;
	}

	public DebtAcnt()
	{
	}

	@Override
	public void deposit(double amount)
	{
		if (amount > 0)
		{
			throw new IllegalStateException(
					"Expect a negative value when decreasing debt");
		} else
		{

			balance += amount;
		}
	}

	@Override
	public double withdraw(double amount)
	{
		if (amount > highThreshold - balance)
		{
			throw new IllegalStateException("Debt has Insufficient Funds");
		} else
		{
			balance += amount;
			return amount;
		}
	}

	@Override
	public void doTimeTick()
	{

		double interest = balance * monthlyInterestRate;
		balance += interest;
		// draw minimum balance from checking
		// formula as described in:
		//     http://www.bankrate.com/brm/news/debt/20050503b1.asp
		//     https://www.lendingtree.com/credit-cards/credit-card-minimum-payments-article
		double minimum_payment = (balance * MINIMUM_PAYMENT_PERCENT);
		balance -= underFlowAccount.withdraw(minimum_payment);
	}

}
